<!DOCTYPE html>


<html lang="zn-CH">


<head>
  <meta charset="utf-8" />
    
  <meta name="description" content="What I can do is to Do My Personal Best!" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    poi-util 加强 POI 相关操作工具包 |  小熊的博客
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="http://www.cdn.adingxiong.com/b5363a06dc744d79a94021492bcefe27" />
  
  
<link rel="stylesheet" href="/blog/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/blog/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/blog/atom.xml" title="小熊的博客" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content on">
      <section class="outer">
  <article id="post-poi-util-加强-POI-相关操作工具包" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  poi-util 加强 POI 相关操作工具包
</h1>
 

    </header>
    

    
    <div class="article-meta">
      <a href="/blog/2021/01/14/poi-util-%E5%8A%A0%E5%BC%BA-POI-%E7%9B%B8%E5%85%B3%E6%93%8D%E4%BD%9C%E5%B7%A5%E5%85%B7%E5%8C%85/" class="article-date">
  <time datetime="2021-01-14T06:42:28.000Z" itemprop="datePublished">2021-01-14</time>
</a>
      
      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">6 min</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># 仓库坐标地址</span><br><span class="line">&lt;dependency&gt;</span><br><span class="line">  &lt;groupId&gt;com.gitee.bodboy&lt;&#x2F;groupId&gt;</span><br><span class="line">  &lt;artifactId&gt;poi-utils&lt;&#x2F;artifactId&gt;</span><br><span class="line">  &lt;version&gt;0.0.2-Release&lt;&#x2F;version&gt;</span><br><span class="line">&lt;&#x2F;dependency&gt;</span><br></pre></td></tr></table></figure>
<section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px; color: black; padding: 0 10px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;"><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; font-weight: bold; color: black; font-size: 22px; border-bottom: 4px rgba(160, 249, 176) solid; display: flex; padding: 0;"><span class="prefix" style="display: none;"></span><span class="content" style="width: 100%; display: flex; color: rgba(160, 249, 176); padding: 0.5rem 1rem; border-top-left-radius: 4px; border-top-right-radius: 4px; background: #181a21 !important;"><code>poi-util</code> 加强<code>POI</code>相关操作工具包</span><span class="suffix"></span></h2>
<h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; font-weight: bold; color: black; font-size: 20px; border-bottom: 4px rgba(160, 249, 176) solid; display: flex; padding: 0;"><span class="prefix" style="display: none;"></span><span class="content" style="width: 100%; display: flex; color: rgba(160, 249, 176); padding: 0.5rem 1rem; border-top-left-radius: 4px; border-top-right-radius: 4px; background: #181a21 !important;">迭代记录</span><span class="suffix" style="display: none;"></span></h3>
<ul data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">2020年11月27日11:33:35 完成Excel导出的部分</section></li></ul>
<h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; font-weight: bold; color: black; font-size: 20px; border-bottom: 4px rgba(160, 249, 176) solid; display: flex; padding: 0;"><span class="prefix" style="display: none;"></span><span class="content" style="width: 100%; display: flex; color: rgba(160, 249, 176); padding: 0.5rem 1rem; border-top-left-radius: 4px; border-top-right-radius: 4px; background: #181a21 !important;">工具包说明</span><span class="suffix" style="display: none;"></span></h3>
<section class="table-container" data-tool="mdnice编辑器" style="overflow-x: auto;"><table style="display: table; text-align: left; border: 1px solid rgba(14, 210, 247, 0.06); margin: 1rem 0;">
<thead>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: white; background: #363636;">
<th style="font-weight: bold; font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; min-width: 85px; background-color: #10222e !important; color: rgba(14, 210, 247, 0.85) !important;">继承工具类</th>
<th style="font-weight: bold; font-size: 16px; border: 1px solid #545454; padding: 5px 10px; min-width: 85px; text-align: center; background-color: #10222e !important; color: rgba(14, 210, 247, 0.85) !important;"></th>
<th style="font-weight: bold; font-size: 16px; border: 1px solid #545454; padding: 5px 10px; min-width: 85px; text-align: right; background-color: #10222e !important; color: rgba(14, 210, 247, 0.85) !important;">完结时间</th>
</tr>
</thead>
<tbody style="border: 0;">
<tr style="border: 0; border-top: 1px solid #ccc; background-color: white; background: #363636;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;">Excel导出</td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;"></td>
</tr>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8; background: #1e1e1e;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;">通用导出<code>fillCustomer</code></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;">2020年11月27日11:33:35</td>
</tr>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: white; background: #363636;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;">定制导出  <code>fillCommon</code></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;">2020年11月27日11:33:35</td>
</tr>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8; background: #1e1e1e;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;">Excel 导入</td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;">2020年11月27日17:16:47</td>
</tr>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: white; background: #363636;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;">Excel转HTML</td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;">开发中</td>
</tr>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8; background: #1e1e1e;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;">WORD模版导出</td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;">开发中</td>
</tr>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: white; background: #363636;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;">Excel 模版导出</td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;">未开发</td>
</tr>
<tr style="border: 0; border-top: 1px solid #ccc; background-color: #F8F8F8; background: #1e1e1e;">
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; text-align: left; color: #dedede; min-width: 85px;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: center;"></td>
<td style="font-size: 16px; border: 1px solid #545454; padding: 5px 10px; color: #dedede; min-width: 85px; text-align: right;"></td>
</tr>
</tbody>
</table>
</section><h4 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;"><span class="prefix" style="display: none;"></span><span class="content">1. 结构说明</span><span class="suffix" style="display: none;"></span></h4>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><img src="https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/ec0bd19b203c47ab9667af5137552791~tplv-k3u1fbpfcp-watermark.image" alt style="display: block; margin: 0 auto; max-width: 100%; border-radius: 5px;"></figure>
<h4 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;"><span class="prefix" style="display: none;"></span><span class="content">2. 使用说明</span><span class="suffix" style="display: none;"></span></h4>
<pre data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px;"><code style="display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; -webkit-overflow-scrolling: touch;">该部分的核心功能是自定义注解，在你需要导出的实体类中，
将你需要作为表头导出的字段加上自定义注解 @FieldName ，
注解的属性有value，为Excel表头名称 require是否必填，默认为否
simpleDate时间格式为，默认为 空  
</code></pre>
<h4 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;"><span class="prefix" style="display: none;"></span><span class="content">3. 调用说明</span><span class="suffix" style="display: none;"></span></h4>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">实体类示例</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://files.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;"><span class="hljs-meta" style="color: #61aeee; line-height: 26px;">@Data</span><br><span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">public</span>&nbsp;<span class="hljs-class" style="line-height: 26px;"><span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">class</span>&nbsp;<span class="hljs-title" style="color: #e6c07b; line-height: 26px;">ProjectVo</span>&nbsp;</span>{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #61aeee; line-height: 26px;">@FieldName</span>(value&nbsp;=&nbsp;<span class="hljs-string" style="color: #98c379; line-height: 26px;">"项目"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;String&nbsp;name;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #61aeee; line-height: 26px;">@FieldName</span>(value&nbsp;=&nbsp;<span class="hljs-string" style="color: #98c379; line-height: 26px;">"电话"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;String&nbsp;phone;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;String&nbsp;person;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #61aeee; line-height: 26px;">@FieldName</span>(value&nbsp;=&nbsp;<span class="hljs-string" style="color: #98c379; line-height: 26px;">"金额"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;Double&nbsp;money;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #61aeee; line-height: 26px;">@FieldName</span>(value&nbsp;=&nbsp;<span class="hljs-string" style="color: #98c379; line-height: 26px;">"负责人"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;String&nbsp;processPeople;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #61aeee; line-height: 26px;">@FieldName</span>(value&nbsp;=&nbsp;<span class="hljs-string" style="color: #98c379; line-height: 26px;">"周期"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;String&nbsp;cycle;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-meta" style="color: #61aeee; line-height: 26px;">@FieldName</span>(value&nbsp;=&nbsp;<span class="hljs-string" style="color: #98c379; line-height: 26px;">"记录日期"</span>,dateFormat&nbsp;=&nbsp;<span class="hljs-string" style="color: #98c379; line-height: 26px;">"yyyy-MM-dd"</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;Date&nbsp;date;<br>}<br><br></code></pre>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">导出功能调用,目前<code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #000000; background: rgba(14, 210, 247, 0.15);">Excel</code>导出分两种</p>
<ul data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;"><p style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">通用导出(默认注解value为表头,根据字段值的长度来自适应宽度,全局字体上下左右居中)</p>
</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;"><p style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">定制导出 (支持多sheet页导出,支持自定义标题,表头,样式,字体等)</p>
</section></li></ul>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content">3.1  通用导出<code>Excel</code></span><span class="suffix" style="display: none;"></span></h5>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">调用方法</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://files.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;">&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Workbook&nbsp;wb&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">new</span>&nbsp;XSSFWorkbook();<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">//模拟数据</span><br>&nbsp;&nbsp;&nbsp;&nbsp;List&lt;ProjectVo&gt;&nbsp;list&nbsp;=&nbsp;mockData();<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">//调用导出方法&nbsp;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">//&nbsp;参数说明&nbsp;wb对象&nbsp;&nbsp;&nbsp;集合数据&nbsp;&nbsp;sheetName&nbsp;默认为sheet</span><br>&nbsp;&nbsp;&nbsp;&nbsp;ExcelExport.getInstance().fillCommon(wb,list,<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">null</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;FileOutputStream&nbsp;out&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">new</span>&nbsp;FileOutputStream(<span class="hljs-string" style="color: #98c379; line-height: 26px;">"C:\\Users\\Administrator\\Desktop\\测试导出.xlsx"</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;wb.write(out);<br>&nbsp;&nbsp;&nbsp;&nbsp;out.close();<br></code></pre>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">效果如下</p>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><img src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/9547864958cf4c8e9c1f6eb1d1896591~tplv-k3u1fbpfcp-watermark.image" alt style="display: block; margin: 0 auto; max-width: 100%; border-radius: 5px;"></figure>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content">3.2 定制导出<code>Excel</code></span><span class="suffix" style="display: none;"></span></h5>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://files.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">//定制excel</span><br>&nbsp;&nbsp;&nbsp;&nbsp;Workbook&nbsp;wb&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">new</span>&nbsp;XSSFWorkbook();<br>&nbsp;&nbsp;&nbsp;&nbsp;Sheet&nbsp;sheet&nbsp;=&nbsp;wb.createSheet(<span class="hljs-string" style="color: #98c379; line-height: 26px;">"定制表头导出"</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;CellStyle&nbsp;cellStyle&nbsp;=&nbsp;wb.createCellStyle();<br>&nbsp;&nbsp;&nbsp;&nbsp;Font&nbsp;font&nbsp;=&nbsp;wb.createFont();<br>&nbsp;&nbsp;&nbsp;&nbsp;List&lt;ProjectVo&gt;&nbsp;list&nbsp;=&nbsp;mockData();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Map&lt;String,&nbsp;List&gt;&nbsp;declaredFieldsInfo&nbsp;=&nbsp;com.adingxiong.poiutils.util.ClassUtils.getDeclaredFieldsInfo(list.get(<span class="hljs-number" style="color: #d19a66; line-height: 26px;">0</span>));<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">int</span>&nbsp;size&nbsp;=&nbsp;declaredFieldsInfo.get(Constants.HEAD).size();<br>&nbsp;&nbsp;&nbsp;&nbsp;sheet.addMergedRegion(<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">new</span>&nbsp;CellRangeAddress(<span class="hljs-number" style="color: #d19a66; line-height: 26px;">0</span>,<span class="hljs-number" style="color: #d19a66; line-height: 26px;">0</span>,<span class="hljs-number" style="color: #d19a66; line-height: 26px;">0</span>,size&nbsp;-<span class="hljs-number" style="color: #d19a66; line-height: 26px;">1</span>&nbsp;));<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">//主体部分</span><br>&nbsp;&nbsp;&nbsp;&nbsp;Row&nbsp;row&nbsp;=&nbsp;sheet.createRow(<span class="hljs-number" style="color: #d19a66; line-height: 26px;">0</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;Cell&nbsp;cell&nbsp;=&nbsp;row.createCell(<span class="hljs-number" style="color: #d19a66; line-height: 26px;">0</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;font.setBold(<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">true</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;font.setFontHeightInPoints((<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">short</span>)&nbsp;<span class="hljs-number" style="color: #d19a66; line-height: 26px;">16</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;CellStyle&nbsp;headStyle&nbsp;=&nbsp;wb.createCellStyle();<br>&nbsp;&nbsp;&nbsp;&nbsp;headStyle.setFont(font);<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">//设置对齐样式</span><br>&nbsp;&nbsp;&nbsp;&nbsp;headStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);<br>&nbsp;&nbsp;&nbsp;&nbsp;headStyle.setFillForegroundColor(HSSFColor.DARK_RED.index);<br>&nbsp;&nbsp;&nbsp;&nbsp;cell.setCellType(<span class="hljs-number" style="color: #d19a66; line-height: 26px;">1</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;cell.setCellValue(<span class="hljs-string" style="color: #98c379; line-height: 26px;">"这是定制的单元格头"</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;cell.setCellStyle(headStyle);<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">//核心导出部分&nbsp;&nbsp;前面部分可以自己定制表头,标题,全局样式,多sheet等&nbsp;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;ExcelExport.getInstance().fillCustomer(sheet,<span class="hljs-number" style="color: #d19a66; line-height: 26px;">1</span>,<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">null</span>,cellStyle,list);<br>&nbsp;&nbsp;&nbsp;&nbsp;FileOutputStream&nbsp;out&nbsp;=&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">new</span>&nbsp;FileOutputStream(<span class="hljs-string" style="color: #98c379; line-height: 26px;">"C:\\Users\\Administrator\\Desktop\\定制导出.xlsx"</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;wb.write(out);<br>&nbsp;&nbsp;&nbsp;&nbsp;out.close();<br></code></pre>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">效果如下所示
<img src="https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/059faeb52cf5493d9f7cf854bf1ad400~tplv-k3u1fbpfcp-watermark.image" alt style="display: block; margin: 0 auto; max-width: 100%; border-radius: 5px;"></p>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4c7ae8622ebd48b8bce304c528697bbb~tplv-k3u1fbpfcp-watermark.image" alt style="display: block; margin: 0 auto; max-width: 100%; border-radius: 5px;"></figure>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content">3.3  <code>Excel</code>导出功能</span><span class="suffix" style="display: none;"></span></h5>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">导入功能还是基于注解部分，会去查找你实体类@Field注解值和Excel表头对应的上的字段，然后将数值对实体类进行数据填充</p>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">实体类注解可以参考导入</p>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">方法调用入口<code style="font-size: 14px; word-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #000000; background: rgba(14, 210, 247, 0.15);">ExcelImport.getInstance().transformation()</code> ,参数说明</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://files.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;"><span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">/**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;标题所在行号&nbsp;默认为&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;Integer&nbsp;rowNum&nbsp;=&nbsp;Integer.valueOf(<span class="hljs-number" style="color: #d19a66; line-height: 26px;">0</span>);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">/**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;是否格式话标题&nbsp;&nbsp;去掉&nbsp;空格&nbsp;&nbsp;换行符<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;Boolean&nbsp;formatTitle&nbsp;=&nbsp;Boolean.valueOf(<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">true</span>);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">/**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;指定存放错误日志的字段名<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;String&nbsp;fieldError&nbsp;=&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">null</span>&nbsp;;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #5c6370; font-style: italic; line-height: 26px;">/**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;指定记录表格行数的字段名<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">private</span>&nbsp;String&nbsp;fieldRows&nbsp;=&nbsp;&nbsp;<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">null</span>;<br></code></pre>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">可以每个参数都有默认值，不设置即认为是默认。可以通过链式操作来设置各个属性值</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://files.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #282c34; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;">List&nbsp;&lt;ProjectVo&gt;&nbsp;list&nbsp;=&nbsp;ExcelImport.getInstance().setRowNum(<span class="hljs-number" style="color: #d19a66; line-height: 26px;">5</span>).setFieldRows(<span class="hljs-string" style="color: #98c379; line-height: 26px;">"rows"</span>).isFormatTitle(<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">true</span>).setFieldError(<span class="hljs-string" style="color: #98c379; line-height: 26px;">"error"</span>).transformation(sheet&nbsp;,ProjectVo<span class="hljs-class" style="line-height: 26px;">.<span class="hljs-keyword" style="color: #c678dd; line-height: 26px;">class</span>)</span>;<br></code></pre>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; font-size: 17px; word-spacing: 3px; letter-spacing: 1px;">导出效果如下所示
<img src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/2c1e961c0af24e05b8d1e449dc0edcbc~tplv-k3u1fbpfcp-watermark.image" alt style="display: block; margin: 0 auto; max-width: 100%; border-radius: 5px;"></p>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content"><a href="https://gitee.com/bodboy/poi-util" target="_blank" rel="noopener" style="text-decoration: none; color: #1e6bb8; word-wrap: break-word; font-weight: bold; border-bottom: 1px solid #1e6bb8;">源代码地址</a>  觉得写的不错的话 可以给个start. 有兴趣的也可以参与代码维护</span><span class="suffix" style="display: none;"></span></h5>
</section>








      
      <!-- reward -->
      
      <div id="reward-btn">
        Donate
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>Copyright： </strong>
              Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://bodboy.gitee.io/blog/2021/01/14/poi-util-%E5%8A%A0%E5%BC%BA-POI-%E7%9B%B8%E5%85%B3%E6%93%8D%E4%BD%9C%E5%B7%A5%E5%85%B7%E5%8C%85/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/poi/" rel="tag">poi</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/blog/2021/01/14/IDEA-%E8%87%AA%E5%AE%9A%E4%B9%89%E5%BF%AB%E6%8D%B7%E4%BB%A3%E7%A0%81%E5%9D%97/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            IDEA 自定义快捷代码块
          
        </div>
      </a>
    
    
      <a href="/blog/2020/11/25/vue-cli%E5%88%9D%E6%AC%A1%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE%E4%BF%9D%E5%AD%98%E9%A2%84%E7%95%99%E8%AE%BE%E7%BD%AE%E5%A6%82%E4%BD%95%E5%8E%BB%E6%8E%89/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">vue-cli初次创建项目保存预留设置如何去掉</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'uW8QYGvvhWmNWdiwpznJ0GVa-gzGzoHsz',
        app_key: 'LrJhMzx9qEwcMV1DJjTI6f6C',
        path: window.location.pathname,
        notify: 'false',
        verify: 'false',
        avatar: '[object Object]',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2019-2021
        <i class="ri-heart-fill heart_icon"></i> panda
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/blog/"><img src="https://portrait.gitee.com/uploads/avatars/user/1007/3023420_bodboy_1578973210.png!avatar200" alt="小熊的博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/blog/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/blog/js/jquery-2.0.3.min.js"></script>


<script src="/blog/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/blog/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/blog/dist/main.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>




<script src="/blog/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>

  
<script src="/blog/js/clickLove.js"></script>



<!-- 复制 -->



    
    <div id="music">
    
    
    
    <iframe frameborder="no" border="1" marginwidth="0" marginheight="0" width="200" height="52"
        src="//music.163.com/outchain/player?type=2&id=1297802566&auto=1&height=32"></iframe>
</div>

<style>
    #music {
        position: fixed;
        right: 15px;
        bottom: 0;
        z-index: 998;
    }
</style>
    
  </div>
</body>

</html>